package com.wordlearning.third;

import com.wordlearning.third.audio.TtsService;
import com.wordlearning.third.audio.impl.KittenTtsServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 第三方服务配置类
 * 注册第三方服务相关的Spring bean
 */
@Configuration
public class ThirdPartyServiceConfig {
    
    // Kitten TTS API配置
    @Value("${kitten.tts.api.url:http://localhost:8000}")
    private String kittenTtsApiUrl;
    
    @Value("${kitten.tts.api.timeout:30000}")
    private int kittenTtsApiTimeoutMs;
    
    /**
     * 注册Kitten TTS服务实现
     * @return KittenTtsServiceImpl实例
     */
    @Bean
    public TtsService kittenTtsService() {
        // 使用配置的参数创建服务实例
        return new KittenTtsServiceImpl(kittenTtsApiUrl, kittenTtsApiTimeoutMs);
    }
    
    /**
     * 注册第三方服务管理类
     * @param ttsService TTS服务实例
     * @return ThirdPartyServiceManager实例
     */
    @Bean
    public ThirdPartyServiceManager thirdPartyServiceManager(TtsService ttsService) {
        return new ThirdPartyServiceManager(ttsService);
    }
}